package test_achieve.courierapp;

import constant.Constant;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
 * Created by chenkuo on 2017/11/20.
 */
public class CourierMethod {

    /**今日订单页，订单数量*/
    public static int TodayOrderNumber(){
        List<WebElement> TodyOrderNumber = Constant.driverCourier.findElements(By.id("tasknum_txt"));
        int num = TodyOrderNumber.size();
        return num;
    }

    /**今日订单页，处于第几个订单*/
    public static int TodayOrderLine(String orderNumbuter){
        int count =TodayOrderNumber();
        List <WebElement> nums = Constant.driverWeb.findElements(By.id("tasknum_txt"));
        for (int i=0;i<count;i++){
            String num = nums.get(i).getText();
            if (orderNumbuter.equals(num)){
                return i;
            }
        }
        return 0;
    }


    /**今日订单列表，根据订单查看，字符串是否存在*/
    public static boolean qeuryAllOrderContent(String orderNumbuter,String contant) {
        boolean flag = false;
        int count = TodayOrderLine(orderNumbuter);
        List<WebElement> TodyOrderNumber = Constant.driverCourier.findElements(By.className("android.widget.LinearLayout"));
        System.out.println("今日订单："+TodyOrderNumber.get(count).getText());
        return TodyOrderNumber.get(count).getText().contains(contant);
    }
}
